<template>
	<view>
		<view class="list" v-if="pageName == 'scenic'">
			<view class="item tp-w690" v-for="(item,index) in youhuidata" :key="index">
				<view class="l-wrap">
					<view class="price"><text style="font-size: 32rpx;">￥</text>{{item.amount}}</view>
					<!-- <view class="tip">满100-10</view> -->
					<view class="btn" v-if="item.isTake==1" @click="lqyouhui(item)">立即领取</view>
					<view class="btn" v-if="item.isTake==0">已领取</view>
					<!-- <view class="btn"  >未开始</view> -->
				</view>
				<view class="r-wrap">
					<view class="other-wrap">
						<image class="icon" src="../static/icon/shop.png"></image>
						<view class="txt">{{item.jqName}}</view>
					</view>
					<view class="name">{{item.couponName}}</view>
					<view class="date">有效期：{{item.beginTime}}-{{item.endTime}}</view>
					<!-- <view class="date useof">使用范围：2012</view> -->

				</view>
				<uni-icons class="help-icon" type="help" size="20" color="#FFAF3C" @click="goxq(item.content)"></uni-icons>
			</view>
		</view>
		<view class="list" v-if="pageName == 'travel'">
			<view class="item tp-w690" v-for="(item,index) in youhuidata" :key="index">
				<view class="l-wrap">
					<view class="price"><text style="font-size: 32rpx;">￥</text>{{item.amount}}</view>
					<view class="tip" v-if="item.useScene == 0">不限制</view>
					<view class="tip" v-if="item.useScene == 1">满{{item.fullAmount}} - {{item.amount}}</view>
					<view class="btn" v-if="item.status==0" @click="lqyouhui(item)">立即领取</view>
					<view class="btn" v-if="item.status==1">已领取</view>
					<view class="btn" v-if="item.status==2">未开始</view>
				</view>
				<view class="r-wrap">
					<view class="other-wrap">
						<image class="icon" src="../static/icon/shop.png"></image>
						<view class="txt">{{item.bound}}</view>
					</view>
					<view class="name">{{item.couponName}}</view>
					<view class="date">有效期：{{item.beginTime}}-{{item.endTime}}</view>
					<!-- <view class="date useof">使用范围：2012</view> -->

				</view>
				<uni-icons class="help-icon" type="help" size="20" color="#FFAF3C" @click="goxq(item.content)"></uni-icons>
			</view>
		</view>
		<!-- 图片 S -->
		<view class="tp-m0a tu1 tp-mt20">
			<image class="" src="../static/scenic/guanggao.png" mode=""></image>
		</view>
		<view class="level_align flex_between tp-ptb0lr30 tp-mt20">
			<view class="tu2 ">
				<image class="" src="../static/scenic/guanggao1.png" mode=""></image>
			</view>
			<view class="tu2 ">
				<image class="" src="../static/scenic/guanggao1.1.png" mode=""></image>
			</view>
		</view>
		<view class="tp-m0a tu1 tp-mt20">
			<image class="" src="../static/scenic/guanggao2.png" mode=""></image>
		</view>
		<!-- 图片 E -->
		<!-- 暂无数据 S-->
		<view class="available" v-if="youhuidata.length == 0">
			<image src="../static/wu.png" mode=""></image>
			<text>该景区暂无优惠券</text>
		</view>
		<!-- 暂无数据 E-->
	</view>
</template>

<script>
	export default {
		props: {

		},
		data() {
			return {
				pageName: 'scenic', // hotel 酒店  scenic 景区  travel 旅游
				id: '',
				thisid: '', //选中的优惠劵id
				youhuidata: [],
			};
		},
		onLoad(opt) {
			console.log(opt)
			this.pageName = opt.pageName
			this.id = opt.id
			this.getlist()
		},
		methods: {
			getlist() {
				let url = ''
				if (this.pageName == 'scenic') {
					url = this.$api.scenicYh + '?jqId=' + this.id
				} else if (this.pageName == 'travel') {
					url = this.$api.travelGroupCouponList + '?travelId=' + this.id
				}
				this.$http.get(url).then(res => {
					if (res.code == 200) {
						this.youhuidata = res.data
					}
				})
			},
			//领取优惠劵
			lqyouhui(item) {
				let url = ''
				if (this.pageName == 'scenic') {
					url = this.$api.scenicLqyh + '?jqCouponId=' + item.jqCouponId
				} else if (this.pageName == 'travel') {
					url = this.$api.travelGroupReceiveCoupon + '?id=' + item.id
				}
				this.$http.get(url).then(res => {
					if (res.code == 200) {
						this.getlist()
						uni.showToast({
							title: '领取成功',
							icon: 'none',
						})
					}
				})
			},
			goxq(content) {
				uni.navigateTo({
					url: '/pagesSecond/scenic/scenicTxt?name=优惠券说明&content=' + encodeURIComponent(JSON.stringify(content))
				})
			},
			// 跳转到优惠券说明
			/* handleGoCouponDetail(id) { 
				console.log('id', id);
				uni.navigateTo({
					url: '/pagesTravel/couponDetail?id=' + id
				})
			}, */
			/* handleGetCoupon(id) {
				this.$http.get(this.$api.receiveCoupon, {id}).then(res => {
					if (res.code === 200) {
						uni.showToast({title: '领取成功'})
						uni.$emit('getCopponSuccess',  this.dateInfo)
					}
				})
			}, */
			// 显示提示
			/* showToast(status,time){
				uni.showToast({
					title: status == 1?'这个优惠券次数领完了':time+'过后才可以领取',
					icon:"none"
				})
				} */
		}
	}
</script>

<style lang="scss" scoped>
	.tu1 {
		width: 690rpx;
		height: 222rpx;
	}

	.tu2 {
		width: 335rpx;
		height: 128rpx;
	}

	.list {
		.item {
			margin-top: 20rpx;
			display: flex;
			background-color: #fff;
			position: relative;

			&::before,
			&::after {
				content: '';
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				width: 20rpx;
				height: 20rpx;
				border-radius: 50%;
				background-color: #f5f5f5;
			}

			&::before {
				left: -10rpx;
			}

			&::after {
				right: -10rpx;
			}

			.help-icon {
				position: absolute;
				right: 20rpx;
				top: 20rpx;
				z-index: 1;
			}

			.l-wrap {
				display: flex;
				align-items: center;
				flex-direction: column;
				padding: 40rpx 0;
				justify-content: space-between;
				background-color: #FF660A;
				color: #fff;
				margin-right: 39rpx;
				width: 200rpx;

				.price {
					font-size: 48rpx;
					font-weight: 500;
					line-height: 1;
				}

				.tip {
					font-size: 24rpx;
					margin-top: 24rpx;
				}

				.btn {
					width: 160rpx;
					height: 48rpx;
					line-height: 48rpx;
					text-align: center;
					border: 1px solid #fff;
					border-radius: 24rpx;
					color: #fff;
					margin-top: 38rpx;
				}
			}

			.r-wrap {
				display: flex;
				flex-direction: column;

				.other-wrap {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-weight: 500;
					margin: 42rpx 0 22rpx;

					.icon {
						margin-right: 14rpx;
						height: 27rpx;
						width: 27rpx;
					}
				}

				.name {
					font-size: 28rpx;
					font-weight: 500;
					margin-top: 30rpx;
					line-height: 1;
				}

				.date {
					font-size: 22rpx;
					color: #666;
					margin: 20rpx 0 0;
					line-height: 40rpx;

					&.useof {
						margin-top: 30rpx;
						line-height: 36rpx;
					}
				}

				.btn {
					width: 160rpx;
					height: 48rpx;
					line-height: 48rpx;
					text-align: center;
					border: 1px solid $red;
					border-radius: 24rpx;
					color: $red;
				}
			}
		}
	}

	.bottom {
		width: 90%;
		margin: 0 auto;
		padding: 20rpx 0 0 0;

		.guanggao {
			height: 222rpx;
		}
	}
	.available {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		height: calc(100vh - 444rpx - 128rpx - 100rpx);
		image {
			width: 200rpx;
			height: 116rpx;
		}
		text {
			color: #999999;
			font-size: 26rpx;
			margin-top: 20rpx;
		}
	}
</style>
